package com.xpgk.mvc.ddc.maintenance.plateMaintenance;

import com.jfinal.log.Log;
import com.xpgk.annotation.Service;
import com.xpgk.constant.ConstantRender;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseService;

@Service(name = PlateMaintenanceService.serviceName)
public class PlateMaintenanceService extends BaseService{

	@SuppressWarnings("unused")
	private static final Log log = Log.getLog(PlateMaintenanceService.class);

	public static final String serviceName = "plateMaintenanceService";
	
	/**
	 * 添加产品
	 * @param user
	 * @param organIds
	 * @return
	 */
	public RenderBean addPlate(PlateMaintenance plateMaintenance){
		RenderBean result = new RenderBean();
		String sql = getSqlMy(PlateMaintenance.sqlId_selectByPlateNumber);
		PlateMaintenance pm = PlateMaintenance.dao.findFirst(sql,plateMaintenance.getStr(PlateMaintenance.column_number11));
		if(pm!=null){
			result.setCode(ConstantRender.render_error_code);
			result.setMsg("车牌编号重复！");
		}else{
			plateMaintenance.set(PlateMaintenance.column_dataStatus, "1");
			if(!plateMaintenance.save()){
				result.setCode(ConstantRender.render_error_code);
				result.setMsg("保存失败！");
			}else{
				result.setCode(ConstantRender.render_success_code);
				result.setMsg("保存成功！");
			}
		}
		
		return result;
	}
	
	/**
	 * 编辑产品
	 * @param user
	 * @param organIds
	 * @return
	 */
	public RenderBean upPlate(PlateMaintenance plateMaintenance){
		RenderBean result = new RenderBean();
		if(!plateMaintenance.update()){
			result.setCode(ConstantRender.render_error_code);
			result.setMsg("修改失败！");
		}else{
			result.setCode(ConstantRender.render_success_code);
			result.setMsg("修改成功！");
		}
		return result;
	}

}
